package com.oocl.ita.sakura.protocol;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Protocol implements Serializable {
	String msgType;
	Map<String, Object> params;

	public String getMsgType() {
		return msgType;
	}

	public void setMsgType(String msgType) {
		this.msgType = msgType;
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public void setParams(Map<String, Object> params) {
		this.params = params;
	}

	public Protocol(String msgType, Map<String, Object> params) {
		this.msgType = msgType;
		this.params = params;
	}
	
	public Protocol(String msgType) {
		this.msgType = msgType;
		this.params = new HashMap();
	}
	
	public void encapsulate(String field, Object obj) {
		params.put(field, obj);
	}

	@Override
	public String toString() {
		String result = "MsgType : " + msgType;
		Iterator<Map.Entry<String, Object>> entries = params.entrySet().iterator();
		while (entries.hasNext()) {
			result += entries.next();
		}
		return result;
	}
	
	
}